package kuonjisai.swing.jdbc;

public class J26_SungJukService {

	private static J26_SungJukDAO sjdao;
	
	
	public J26_SungJukService() {
		sjdao = new J26_SungJukDAO();
		
		
	}
	
	
	
	
	
	public boolean createSungJuk( J26_SungJukVO sj ){
		computeSungJuk( sj );
		
		
		
		return sjdao.insertSungJuk( sj );
		
		
		
	}
	
	
	
	public void computeSungJuk(  J26_SungJukVO sj  ) {
		int tot =  Integer.parseInt( sj.getKor() ) + Integer.parseInt( sj.getEng() )+  Integer.parseInt ( sj.getMat() );
		float avg = ( float )tot / 3;
		switch ( (int)avg / 10 ){
			case 10 : case 9 : sj.setGrd( "수" ); break;
			case 8 : sj.setGrd( "우" ); break;
			case 7 : sj.setGrd( "미" ); break;
			case 6 : sj.setGrd( "양" ); break;
			default : sj.setGrd(  "가" ); break;
			
			
		}
		
		sj.setTot( tot  + "" );
		sj.setAvg( avg  + "" );
		
	}
	
	
	
	
	
	
	
	
} // class
